
package api.dialogs;

import java.awt.EventQueue;

import javax.swing.JDialog;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import javax.swing.border.EmptyBorder;
import java.awt.Color;
import java.awt.Font;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.JSpinner;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.SpinnerNumberModel;
import javax.swing.JButton;
import javax.swing.JSeparator;

public class InicializarDialog extends JDialog {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JPanel contentPanel;
	public JSpinner spFilas;
	public JSpinner spCols;
	public JButton btnAceptar;
	public JSpinner spinnerIX;
	public JSpinner spinnerIY;
	public JSpinner spinnerFX;	
	public JSpinner spinnerFY;
	public JLabel lblError;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					InicializarDialog dialog = new InicializarDialog();
					dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
					dialog.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the dialog.
	 */
	public InicializarDialog() {
		setResizable(false);
		getContentPane().setFont(new Font("Lucida Grande", Font.PLAIN, 13));
		getContentPane().setForeground(Color.BLACK);
		setTitle("Inicializar tablero");
		setModal(true);
		setBounds(100, 100, 315, 344);
		
		contentPanel = new JPanel();
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		
		JLabel lblFilas = new JLabel("Numero de filas:");
		lblFilas.setFont(new Font("Lucida Grande", Font.PLAIN, 13));
		
		JLabel lblCols = new JLabel("Numero de columnas:");
		lblCols.setFont(new Font("Lucida Grande", Font.PLAIN, 13));
		
		spFilas = new JSpinner();
		spFilas.setModel(new SpinnerNumberModel(5, 1, 80, 1));
		
		spCols = new JSpinner();
		spCols.setModel(new SpinnerNumberModel(5, 1, 80, 1));
		
		JLabel lblPIni = new JLabel("Posicion inicial:");
		lblPIni.setFont(new Font("Lucida Grande", Font.PLAIN, 13));
		
		JLabel lblPosicionFinal = new JLabel("Posicion final:");
		lblPosicionFinal.setFont(new Font("Lucida Grande", Font.PLAIN, 13));
		
		JSeparator separator = new JSeparator();
		
		JLabel lblPosicionesRobot = new JLabel("Posiciones Robot");
		lblPosicionesRobot.setFont(new Font("Lucida Grande", Font.BOLD, 14));
		
		JLabel lblDimensionesTablero = new JLabel("Dimensiones Tablero");
		lblDimensionesTablero.setFont(new Font("Lucida Grande", Font.BOLD, 14));
		
		JSeparator separator_1 = new JSeparator();
		
		JLabel lblX = new JLabel("x");
		lblX.setFont(new Font("Lucida Grande", Font.BOLD, 14));
		
		JLabel lblY = new JLabel("y");
		lblY.setFont(new Font("Lucida Grande", Font.BOLD, 14));
		
		spinnerIX = new JSpinner();
		spinnerIX.setModel(new SpinnerNumberModel(0, 0, 4, 1));
		
		spinnerIY = new JSpinner();
		spinnerIY.setModel(new SpinnerNumberModel(0, 0, 4, 1));
		
		spinnerFX = new JSpinner();
		spinnerFX.setModel(new SpinnerNumberModel(0, 0, 4, 1));
		
		spinnerFY = new JSpinner();
		spinnerFY.setModel(new SpinnerNumberModel(0, 0, 4, 1));
		
		lblError = new JLabel("Las posiciones Inicial y Final no pueden coincidir");
		lblError.setForeground(Color.RED);
		lblError.setFont(new Font("Lucida Grande", Font.PLAIN, 9));
		GroupLayout gl_contentPanel = new GroupLayout(contentPanel);
		gl_contentPanel.setHorizontalGroup(
			gl_contentPanel.createParallelGroup(Alignment.TRAILING)
				.addGroup(gl_contentPanel.createSequentialGroup()
					.addGap(27)
					.addGroup(gl_contentPanel.createParallelGroup(Alignment.TRAILING)
						.addGroup(gl_contentPanel.createSequentialGroup()
							.addGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING)
								.addGroup(gl_contentPanel.createSequentialGroup()
									.addGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING)
										.addComponent(lblCols)
										.addComponent(lblFilas))
									.addGap(29)
									.addGroup(gl_contentPanel.createParallelGroup(Alignment.TRAILING, false)
										.addComponent(spFilas, 0, 0, Short.MAX_VALUE)
										.addComponent(spCols, GroupLayout.PREFERRED_SIZE, 48, Short.MAX_VALUE)))
								.addGroup(gl_contentPanel.createSequentialGroup()
									.addGroup(gl_contentPanel.createParallelGroup(Alignment.TRAILING, false)
										.addGroup(gl_contentPanel.createSequentialGroup()
											.addComponent(lblPIni)
											.addGap(48)
											.addComponent(spinnerIX, GroupLayout.PREFERRED_SIZE, 45, GroupLayout.PREFERRED_SIZE))
										.addGroup(gl_contentPanel.createSequentialGroup()
											.addComponent(lblPosicionFinal)
											.addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
											.addComponent(spinnerFX, GroupLayout.PREFERRED_SIZE, 45, GroupLayout.PREFERRED_SIZE)))
									.addPreferredGap(ComponentPlacement.UNRELATED)
									.addGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING)
										.addComponent(spinnerIY, GroupLayout.PREFERRED_SIZE, 43, GroupLayout.PREFERRED_SIZE)
										.addComponent(spinnerFY, GroupLayout.PREFERRED_SIZE, 43, GroupLayout.PREFERRED_SIZE))))
							.addContainerGap(31, Short.MAX_VALUE))
						.addGroup(gl_contentPanel.createSequentialGroup()
							.addComponent(lblX)
							.addGap(47)
							.addComponent(lblY)
							.addGap(58))))
				.addGroup(gl_contentPanel.createSequentialGroup()
					.addGap(75)
					.addComponent(lblDimensionesTablero)
					.addContainerGap(76, Short.MAX_VALUE))
				.addGroup(gl_contentPanel.createSequentialGroup()
					.addContainerGap(92, Short.MAX_VALUE)
					.addComponent(lblPosicionesRobot)
					.addGap(88))
				.addGroup(gl_contentPanel.createSequentialGroup()
					.addContainerGap()
					.addComponent(separator_1, GroupLayout.DEFAULT_SIZE, 293, Short.MAX_VALUE)
					.addContainerGap())
				.addGroup(gl_contentPanel.createSequentialGroup()
					.addContainerGap()
					.addComponent(separator, GroupLayout.DEFAULT_SIZE, 299, Short.MAX_VALUE))
				.addGroup(gl_contentPanel.createSequentialGroup()
					.addContainerGap(41, Short.MAX_VALUE)
					.addComponent(lblError)
					.addGap(39))
		);
		gl_contentPanel.setVerticalGroup(
			gl_contentPanel.createParallelGroup(Alignment.TRAILING)
				.addGroup(gl_contentPanel.createSequentialGroup()
					.addComponent(lblDimensionesTablero)
					.addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
					.addComponent(separator_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
					.addPreferredGap(ComponentPlacement.UNRELATED)
					.addGroup(gl_contentPanel.createParallelGroup(Alignment.TRAILING)
						.addComponent(lblFilas)
						.addComponent(spFilas, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(ComponentPlacement.RELATED)
					.addGroup(gl_contentPanel.createParallelGroup(Alignment.TRAILING)
						.addComponent(lblCols)
						.addComponent(spCols, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addGap(30)
					.addComponent(lblPosicionesRobot)
					.addGap(1)
					.addComponent(separator, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addGroup(gl_contentPanel.createParallelGroup(Alignment.TRAILING)
						.addComponent(lblPIni)
						.addGroup(gl_contentPanel.createSequentialGroup()
							.addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE)
								.addComponent(lblX)
								.addComponent(lblY))
							.addPreferredGap(ComponentPlacement.RELATED)
							.addGroup(gl_contentPanel.createParallelGroup(Alignment.TRAILING)
								.addComponent(spinnerIX, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(spinnerIY, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
					.addPreferredGap(ComponentPlacement.RELATED)
					.addGroup(gl_contentPanel.createParallelGroup(Alignment.TRAILING)
						.addComponent(lblPosicionFinal)
						.addComponent(spinnerFX, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addComponent(spinnerFY, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(lblError, GroupLayout.PREFERRED_SIZE, 11, GroupLayout.PREFERRED_SIZE))
		);
		contentPanel.setLayout(gl_contentPanel);
		
		
		JPanel buttonPanel = new JPanel();
		getContentPane().add(buttonPanel, BorderLayout.SOUTH);
		
		btnAceptar = new JButton("Aceptar");
		btnAceptar.setEnabled(false);
		btnAceptar.setFont(new Font("Lucida Grande", Font.PLAIN, 11));
		buttonPanel.add(btnAceptar);
	}
}
